<template>
	<view></view>
</template>

<script>
	export default {
		methods: {
			open() {
				uni.scanCode({
					success: (res) => {
						console.log('扫码成功：' + res.result);
						uni.showModal({
							title: '扫码成功，结果是',
							content: res.result,
							showCancel: false
						});
						this.$emit('scanSuccess', res.result);
					},
					fail: (err) => {
						console.error('扫码失败：' + err);
						uni.showToast({
							title: '扫码失败',
							icon: 'none'
						});
						this.$emit('scanError');
					}
				});
			}
		}
	}
</script>